#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
long long T,n,m,L,V,d[N],v[N],a[N],p;
int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    while(T--){
        scanf("%lld%lld%lld%lld",&n,&m,&L,&V);
        long long mx=0,cnt=0;
        for(int i=1;i<=n;i++)scanf("%lld%lld%lld",&d[i],&v[i],&a[i]);
        for(int i=1;i<=m;i++)scanf("%lld",&p),mx=max(mx,p);
        for(int i=1;i<=n;i++)
            if(a[i]!=0){if(((V-v[i])*(V+v[i])/2.0/a[i]+d[i]-0.0000001<=mx)&&(d[i]<=mx))cnt++;}
            else if(V<v[i]&&d[i]<=mx)cnt++;
        if(cnt)m--;
        printf("%lld %lld\n",cnt,m);
    }return 0;
}
